package com.xfgg.cloud.boot.util;

import io.micrometer.core.lang.NonNull;
import io.micrometer.core.lang.NonNullApi;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;

import java.util.Objects;

/**
 * 避免Bean名称重名
 *
 * @author xfgg
 */
@NonNullApi
public class UniqueNameGenerator extends AnnotationBeanNameGenerator {
    @Override
    public String generateBeanName(BeanDefinition definition, @NonNull BeanDefinitionRegistry registry) {
        //全限定类名
        return Objects.requireNonNull(definition.getBeanClassName());
    }
}
